<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title">更新物流</h4>
</div>
<form id="logistics-form" action="/xqc/overseas-in/os-ajax" method="post">
    <div class="modal-body">
        <div style="margin-bottom: 10px;">发货单号：{{ $delivery->delivery_no }}</div>
        <div class="form-group">
            <label style="padding-top: 8px;" class="col-sm-3 control-label">物流公司</label>
            <div class="col-sm-8">
                <select id="express_company_id" name="param[express_company_id]">
                    {{ getOptions(\App\Models\Basics\ExpressCompany::options(),$delivery->logistics->express_company_id ?? null) }}
                </select>
            </div>
        </div>
        <div class="form-group">
            <label style="padding-top: 8px;" class="col-sm-3 control-label">物流渠道</label>
            <div class="col-sm-8">
                <select id="express_channel_id" name="param[express_channel_id]">
                    {{ getOptions(\App\Models\Basics\ExpressChannel::options(['area_id' => $delivery->area_id]),$delivery->logistics->express_channel_id ?? null) }}
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="tracking_no" style="padding-top: 8px;" class="col-sm-3 control-label">追踪号</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" id="tracking_no" name="param[tracking_no]" value="{{ $delivery->logistics->tracking_no ?? '' }}" placeholder="追踪号">
            </div>
        </div>
        <div class="form-group">
            <label for="total_weight" style="padding-top: 8px;" class="col-sm-3 control-label">发货公斤数</label>
            <div class="col-sm-8">
                <input type="text" class="form-control decimal_num_" id="total_weight" name="param[total_weight]" value="{{ $delivery->logistics->total_weight ?? '' }}" placeholder="发货公斤数">
            </div>
        </div>
        <div class="form-group">
            <label for="shipping_fee" style="padding-top: 8px;" class="col-sm-3 control-label">运费</label>
            <div class="col-sm-8">
                <input type="text" class="form-control decimal_num_" id="shipping_fee" name="param[shipping_fee]" value="{{ $delivery->logistics->shipping_fee ?? '' }}" placeholder="运费(人民币)">
            </div>
        </div>
        <div class="form-group">
            <label for="other_fee" style="padding-top: 8px;" class="col-sm-3 control-label">其它费用</label>
            <div class="col-sm-8">
                <input type="text" class="form-control decimal_num_" id="other_fee" name="param[other_fee]" value="{{ $delivery->logistics->other_fee ?? '' }}" placeholder="关税+手续(人民币)">
            </div>
        </div>
        <div class="form-group">
            <label for="arrived_at" style="padding-top: 8px;" class="col-sm-3 control-label">到货日期</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" id="arrived_at" name="param[arrived_at]" value="{{ $delivery->logistics->arrived_at ?? '' }}" placeholder="到货日期">
            </div>
        </div>
    </div>
    <div class="modal-footer">
        {{ csrf_field() }}
        <input type="hidden" name="param[id]" value="{{ $id }}">
        <input type="hidden" name="action" value="doLogistics">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="submit" class="btn btn-primary">提交</button>
    </div>
</form>
<script language="JavaScript" type="text/javascript">
    $(function () {
        $("#express_company_id").select2({"allowClear":true, "placeholder":"请选择物流公司","width": '100%'});
        $("#express_channel_id").select2({"allowClear":true, "placeholder":"请选择物流渠道","width": '100%'});
        $('#arrived_at').datetimepicker({"format":"YYYY-MM-DD","locale":"zh-CN","useCurrent":true});
        $(".decimal_num_").inputmask("decimal",
            {
                digits: 3,
                onKeyValidation: function () {
                    if($(this).val()< 0){
                        $(this).val('');
                    }
                }
            }
        );
        $("#logistics-form").ajaxForm(function (data) {
            if (typeof data === 'object') {
                if (data.status) {
                    $("#uploadModal").modal('hide');
                    $(".modal-backdrop").remove();
                    $('body').removeClass('modal-open');
                    toastr.success('提交成功 !');
                    $.pjax.reload('#os-delivery-form');
                } else {
                    swal(data.message, '', 'error');
                }
            }
        });
    });
</script>
